#include "ConsoleMediator.h"


list<DVDPlayer*>	DVDPlayers;
list<VCRPlayer*>	VCRPlayers;
list<CDPlayer*>		CDPlayers;

void ConsoleMediator::deleteAllPlayers()
{
	for (list<DVDPlayer*>::iterator iter = DVDPlayers.begin(); iter != DVDPlayers.end(); iter++)
	{
		delete *iter;
	}
	for (list<VCRPlayer*>::iterator iter = VCRPlayers.begin(); iter != VCRPlayers.end(); iter++)
	{
		delete *iter;
	}
	for (list<CDPlayer*>::iterator iter = CDPlayers.begin(); iter != CDPlayers.end(); iter++)
	{
		delete *iter;
	}
}


void ConsoleMediator::addDVDPlayer(DVDPlayer* dvdPlayer)
{
	if (find(DVDPlayers.begin(), DVDPlayers.end(), dvdPlayer) == DVDPlayers.end())
	{
		DVDPlayers.push_back(dvdPlayer);
	}
}

void ConsoleMediator::addVCRPlayer(VCRPlayer* vcrPlayer)
{
	if (find(VCRPlayers.begin(), VCRPlayers.end(), vcrPlayer) == VCRPlayers.end())
	{
		VCRPlayers.push_back(vcrPlayer);
	}
}
void ConsoleMediator::addCDPlayer(CDPlayer* cdPlayer)
{
	if (find(CDPlayers.begin(), CDPlayers.end(), cdPlayer) == CDPlayers.end())
	{
		CDPlayers.push_back(cdPlayer);
	}
}


void ConsoleMediator::DVDstart(DVDPlayer* dvdPlayer)
{
	if (currentPlayer == 0 || currentPlayer != dvdPlayer)
	{
		if (find(DVDPlayers.begin(), DVDPlayers.end(), dvdPlayer) != DVDPlayers.end())
		{
			if (currentPlayer !=0 )
			{ 
				currentPlayer->stop();
			}
			currentPlayer = dvdPlayer;
		}
	}
}

void ConsoleMediator::VCRstart(VCRPlayer* vcrPlayer)
{
	if (currentPlayer == 0 || currentPlayer != vcrPlayer)
	{
		if (find(VCRPlayers.begin(), VCRPlayers.end(), vcrPlayer) != VCRPlayers.end())
		{
			if (currentPlayer !=0 )
			{ 
				currentPlayer->stop();
			}
			currentPlayer = vcrPlayer;
		}
	}
}


void ConsoleMediator::CDstart(CDPlayer* cdPlayer)
{
	if (currentPlayer == 0 || currentPlayer != cdPlayer)
	{
		if (find(CDPlayers.begin(), CDPlayers.end(), cdPlayer) != CDPlayers.end())
		{
			if (currentPlayer !=0 )
			{ 
				currentPlayer->stop();
			}
			currentPlayer = cdPlayer;
		}
	}
}

void ConsoleMediator::DVDstop(DVDPlayer* dvdPlayer)
{
	if (currentPlayer == dvdPlayer) 
	{
		currentPlayer = 0;
	}
}

void ConsoleMediator::VCRstop(VCRPlayer* vcrPlayer)
{
	if (currentPlayer == vcrPlayer) 
	{
		currentPlayer = 0;
	}
}

void ConsoleMediator::CDstop(CDPlayer* cdPlayer)
{
	if (currentPlayer == cdPlayer) 
	{
		currentPlayer = 0;
	}
}

void ConsoleMediator::DVDrewind(DVDPlayer* dvdPlayer){
}

void ConsoleMediator::VCRrewind(VCRPlayer* vcrPlayer){
}

void ConsoleMediator::CDrewind(CDPlayer* cdPlayer){
}

void ConsoleMediator::DVDforward(DVDPlayer* dvdPlayer){
}

void ConsoleMediator::VCRforward(VCRPlayer* vcrPlayer){
}

void ConsoleMediator::CDforward(CDPlayer* cdPlayer){
}